<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html; charset=UTF-8" %>

<div class="body">
    <s:include value="header.jsp" />
    <s:if test="%{#session.user != null}" >
        <div class="search">
            <s:form action="postQuestion">
                <textarea cols="50" rows="3" name="contentQuestion" > </textarea>
                <input type="submit" value="Đăng câu hỏi" class="search_submit" />
            </s:form>
        </div>
    </s:if>
    <div class="question">
        <div class="questionTitle">
            <a><s:property value="question.subject" /></a>
        </div>
        <div style="float:left; clear: both; margin-top: 20px; font-size: 23px;">
            <s:property value="question.content" />
        </div>
        <div class="questionEx">
            Hỏi bởi: <span class="asker"> <a href="#"> <s:property value="question.asker.fullname" /></a> </span>
            <span><s:property value="%{@thesis.haipv.qa.utils.Util@timeFormat(question.createTime)}" /></span>
        </div>
   
    </div>

    <div class="listAnswer">
        <s:set var="qid" value="question.id" />
        <s:set var="askerid" value="question.asker.accountId" />
        <ul>
            <s:iterator value="question.answers" var="a" status="a.canFeedback" >
                <li class="answer">
                    <div class="answerTitle">
                        <p>
                            <s:if test="%{!(#a.numTrust == 0 && #a.numUntrust == 0)}">
                                <s:if test="%{#a.numTrust == 1}" >
                                    <img src="/QAWeb/images/trust.png" />
                                </s:if>
                                <s:else><img src="/QAWeb/images/untrust.png" /></s:else> 
                            </s:if>

                            <s:property value="#a.content" />
                        </p>
                    </div>
                    <div>
                        <div style="float:left">
                            <span class="like" style="margin-right: 10px">
                                <s:if test="#a.canFeedback ==true">
                                    <a href="
                                       <s:url action="doTrust">
                                           <s:param name="qid" value="qid" />
                                           <s:param name="aid" value="#a.id" />
                                           <s:param name="t" value="1" />
                                           <s:param name="asker" value="askerid"/>
                                           <s:param name="uid" value="#a.responder.accountId"/>
                                       </s:url>
                                       " title="Tin cậy">
                                        <img src="/QAWeb/images/like.png" />
                                    </a>
                                </s:if>
                                <s:else>
                                    <s:if test="%{#a.numTrust == 1}">
                                        <img src="/QAWeb/images/trusted.jpg" />
                                    </s:if>
                                    <s:else>
                                        <img src="/QAWeb/images/like.png" />
                                    </s:else>

                                </s:else>
                            </span>
                            <span class="dislike">
                                <s:if test="#a.canFeedback">
                                    <a href="
                                       <s:url action="doTrust">
                                           <s:param name="qid" value="qid" />
                                           <s:param name="aid" value="#a.id" />
                                           <s:param name="t" value="0" />
                                            <s:param name="asker" value="askerid"/>
                                           <s:param name="uid" value="#a.responder.accountId"/>
                                       </s:url>
                                       " title="Không tin cậy">
                                        <img src="/QAWeb/images/unlike.png" />
                                    </a>
                                </s:if>
                                <s:else>
                                    <s:if test="%{#a.numUntrust == 1}">
                                        <img src="/QAWeb/images/untrusted.jpg" />
                                    </s:if>
                                    <s:else>
                                        <img src="/QAWeb/images/unlike.png" />
                                    </s:else>
                                </s:else>
                            </span>
                            <span>
                                 Xếp hạng: <s:property value="#a.rate" />
                            </span>
                        </div>
                        <div style="float:right; margin-left: 100px;">
                            <div style="float:right; margin-left: 10px;">
                                <img src="/QAWeb/images/avatar.jpg" width="100" height="100" />
                            </div>
                            <div style="float:left;">
                                <s:property value="%{@thesis.haipv.qa.utils.Util@timeFormat(#a.createTime)}" /> <br/>
                                <span class="asker"><a href="
                                                       <s:url action="viewAnswer">
                                                           <s:param name="userId" value="#a.responder.accountId" />
                                                       </s:url>
                                                       "><s:property value="#a.responder.fullname" /></a> </span> <br/>
                                <s:if test="%{#a.responder.experienceTrust != -1}" >
                                    Exp: <s:property value="#a.responder.experienceTrust" /> <br/>
                                </s:if>
                                <s:if test="%{#a.responder.referenceTrust != -1}">
                                Rep: <s:property value="#a.responder.referenceTrust " />
                                </s:if>
                                <s:else>
                                    Rep: ---
                                </s:else>
                            </div>
                        </div>
                    </div>
                </li>
            </s:iterator>
        </ul>
    </div>
    <div class="search">
        <s:if test="question.canAnswer">
            <s:form action="postAnswer">
                <s:hidden name="q" value="%{q}" />
                <div><label>Câu trả lời của bạn </label></div>
                <div>
                    <span><textarea cols="50" rows="3" name="answer" > </textarea> </span>
                    <span><input type="submit" value="Gửi" class="search_submit" /> </span>
                </div>
            </s:form>
        </s:if>
    </div>

</div>